Passed
Push — master ( 772c18...ea9505 )
by Rafael S.
02:00
created

scribe(ꞌread 32bit PCM from disk and write to new fileꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 72

Duplication

Lines 72
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 72
loc 72
rs 9.102

15 Functions

Rating   Name   Duplication   Size   Complexity  
A write-32bitPCM.js ➔ ... ➔ it(ꞌsubChunk1Size should be 16ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌaudioFormat should be 1 (PCM)ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌchunkId should be ꞌRIFFꞌꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌblockAlign should be 4ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsamples_ on the new file should have the same length as in the original fileꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌnumChannels should be 1ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsubChunk2Id should be ꞌdataꞌꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsamples.length should be > 0ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌbyteRate should be 192000ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌbitsPerSample should be 32ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsamples_ on the new file should be same as the original fileꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsampleRate should be 48000ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsubChunk2Size should be > 0ꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌformat should be ꞌWAVEꞌꞌ) 3 3 1
A write-32bitPCM.js ➔ ... ➔ it(ꞌsubChunk1Id should be ꞌfmt ꞌꞌ) 3 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/*!
2
 * Copyright (c) 2017 Rafael da Silva Rocha.
3
 * 
4
 */
5
6 View Code Duplication
var assert = require('assert');
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7
8
describe('read 32bit PCM from disk and write to new file', function() {
9
    
10
    let fs = require("fs");
11
    let wavefile = require("../index.js");
12
    let path = "test/files/";
13
    
14
    let wBytes = fs.readFileSync(path + "32bit-48kHz-noBext-mono.wav");
15
    let wav = new wavefile.WaveFile(wBytes);
16
    let wav2 = new wavefile.WaveFile(wav.toBytes());
17
    fs.writeFileSync(path + "/out/32bit-48kHz-noBext-mono.wav", wav2.toBytes());
18
    
19
    it("chunkId should be 'RIFF'",
20
            function() {
21
        assert.equal(wav2.chunkId, "RIFF");
22
    });
23
    it("subChunk1Id should be 'fmt '",
24
            function() {
25
        assert.equal(wav2.subChunk1Id, "fmt ");
26
    });
27
    it("format should be 'WAVE'",
28
            function() {
29
        assert.equal(wav2.format, "WAVE");
30
    });
31
    it("subChunk1Size should be 16",
32
            function() {
33
        assert.equal(wav2.subChunk1Size, 16);
34
    });
35
    it("audioFormat should be 1 (PCM)",
36
            function() {
37
        assert.equal(wav2.audioFormat, 1);
38
    });
39
    it("numChannels should be 1",
40
            function() {
41
        assert.equal(wav2.numChannels, 1);
42
    });
43
    it("sampleRate should be 48000",
44
            function() {
45
        assert.equal(wav2.sampleRate, 48000);
46
    });
47
    it("byteRate should be 192000",
48
            function() {
49
        assert.equal(wav2.byteRate, 192000);
50
    });
51
    it("blockAlign should be 4",
52
            function() {
53
        assert.equal(wav2.blockAlign, 4);
54
    });
55
    it("bitsPerSample should be 32",
56
            function() {
57
        assert.equal(wav2.bitsPerSample, 32);
58
    });
59
    it("subChunk2Id should be 'data'",
60
            function() {
61
        assert.equal(wav2.subChunk2Id, 'data');
62
    });
63
    it("subChunk2Size should be > 0",
64
            function() {
65
        assert.ok(wav2.subChunk2Size > 0);
66
    });
67
    it("samples.length should be > 0",
68
            function() {
69
        assert.ok(wav2.samples_.length > 0);
70
    });
71
    it("samples_ on the new file should have the same length as in the original file",
72
            function() {
73
        assert.equal(wav2.samples_.length, wav.samples_.length);
74
    });
75
    it("samples_ on the new file should be same as the original file",
76
            function() {
77
        assert.deepEqual(wav2.samples_, wav.samples_);
78
    });
79
});
80